import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
} from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { DeputyGeneral } from "./deputy-general.entity";

@Entity("deputy_general_equipment")
@ManualTimestamp()
export class DeputyGeneralEquipment {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ type: "int" })
  deputy_id!: number;

  @Column({ type: "int" })
  equipment_id!: number;

  @Column({ type: "int" })
  equipment_type!: number;

  @Column({ type: "varchar", length: 100 })
  equipment_name!: string;

  @Column({ type: "int", default: 1 })
  equipment_level!: number;

  @Column({ type: "int", default: 1 })
  equipment_quality!: number;

  @Column("text", { nullable: true })
  equipment_attributes!: string;

  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;

  @ManyToOne(() => DeputyGeneral, (deputy) => deputy.equipments)
  @JoinColumn({ name: "deputy_id" })
  deputy!: DeputyGeneral;
}
